import os
import keras
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from keras.models import Model
from keras.layers import *
from matplotlib import pyplot
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
from keras.layers import Dense,Dropout,Activation,Convolution2D,MaxPooling2D,Flatten
from keras.layers import LSTM
def design_model():
    # design network
    inp=Input(shape=(11,5))
    reshape=Reshape((11,5,1))(inp)
    conv1=Convolution2D(32,3,3,border_mode='same',init='glorot_uniform')(reshape)
    print(conv1)
    l1=Activation('relu')(conv1)
    conv2=Convolution2D(64,3,3, border_mode='same',)(l1)
    l2=Activation('relu')(conv2)
    print(l2)
    m2=MaxPooling2D(pool_size=(2, 2), border_mode='valid')(l2)
    print(m2)
    reshape1=Reshape((10,64))(m2)
    lstm1=LSTM(input_shape=(10,64),output_dim=30,activation='tanh',return_sequences=False)(reshape1)
    dl1=Dropout(0.3)(lstm1)
    # den1=Dense(100,activation="relu")(dl1)
    den2=Dense(1,activation="relu")(dl1)
    model=Model(input=inp,outputs=den2)
    model.summary() #打印出模型概况
    adam = keras.optimizers.Adam(lr = 0.001, beta_1=0.95, beta_2=0.999,epsilon=1e-08)
    model.compile(loss=["mae"], optimizer=adam,metrics=['mape'])
    return model
if __name__ == '__main__':
    design_model()